package com.tvein.sanguo.controller.FileLoader
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.common.CommonConstants;
	import com.tvein.sanguo.model.FilesProxy;
//
	public class FileLoad extends SimpleFabricationCommand implements ICommand
	{
		private var filesData:FilesProxy;
		
		override public function execute(notification:INotification) : void
		{
			filesData = facade.retrieveProxy(FilesProxy.NAME) as FilesProxy;
			
			if (notification.getBody() == "/SanGuo/preload.xml")
			{
				sendNotification(CommonConstants.SYSTEM_CONSOLE, ["-moduleInit", "all"]);
			}
			
			for (var i:int = 0; i < filesData.modulesFile.length; i++)
			{
				if (notification.getBody() == filesData.modulesFile[i][1])
				{
					routeNotification(CommonConstants.MODULE_INVOKE, ["-file", notification.getBody()], null, filesData.modulesFile[i][0] + "/*");
					
					filesData.modulesFile.splice(i, 1);
					i --;
				}	
			}
		}
	}
}